package com.anxinr.config;

import com.anxinr.interceptor.MybatisSqlInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * 注册拦截器
 * @author anxinr
 * @describe 告诉mybatis使用这个配置的拦截器
 */
@Configuration
public class MybatisInterceptorConfig {
    /**
     * 注册拦截器
     */
    @Bean
    public MybatisSqlInterceptor mybatisInterceptor() {
        MybatisSqlInterceptor interceptor = new MybatisSqlInterceptor();
        Properties properties = new Properties();
        // 可以调用properties.setProperty方法来给拦截器设置一些自定义参数
        interceptor.setProperties(properties);
        return interceptor;
    }

}
